Skip to content

Conversation

EduardDumitrescu
Copy link
Contributor

Hello,

I've created a branch which exposes methods that would let a developer do a deferred payment on web using the new interop way.

EduardDumitrescu and others added 30 commits June 10, 2024 11:14
… into main

# Conflicts:
#	packages/stripe/CHANGELOG.md
#	packages/stripe/pubspec.yaml
#	packages/stripe_android/CHANGELOG.md
#	packages/stripe_android/pubspec.yaml
#	packages/stripe_platform_interface/pubspec.yaml
#	packages/stripe_web/pubspec.yaml
# Conflicts:
#	packages/stripe_android/CHANGELOG.md
… into web_deffered_payment

# Conflicts:
#	packages/stripe/pubspec.yaml
#	packages/stripe_android/CHANGELOG.md
#	packages/stripe_android/pubspec.yaml
#	packages/stripe_js/CHANGELOG.md
#	packages/stripe_js/lib/src/js/elements/element_creation_options.dart
#	packages/stripe_js/lib/src/js/payment_requests/payment_request.dart
#	packages/stripe_js/pubspec.yaml
#	packages/stripe_platform_interface/CHANGELOG.md
#	packages/stripe_platform_interface/lib/src/models/payment_sheet.dart
#	packages/stripe_platform_interface/lib/src/models/payment_sheet.freezed.dart
#	packages/stripe_platform_interface/lib/src/models/payment_sheet.g.dart
#	packages/stripe_platform_interface/pubspec.yaml
#	packages/stripe_web/CHANGELOG.md
#	packages/stripe_web/lib/src/widgets/payment_element.dart
#	packages/stripe_web/pubspec.yaml
Eduard Dumitrescu added 3 commits September 25, 2024 10:35
… into web_deffered_payment

# Conflicts:
#	packages/stripe/CHANGELOG.md
#	packages/stripe/lib/src/stripe.dart
#	packages/stripe/pubspec.yaml
#	packages/stripe_js/CHANGELOG.md
#	packages/stripe_js/lib/src/js/elements/element_creation_options.dart
#	packages/stripe_js/pubspec.yaml
#	packages/stripe_platform_interface/CHANGELOG.md
#	packages/stripe_platform_interface/pubspec.yaml
#	packages/stripe_web/CHANGELOG.md
#	packages/stripe_web/lib/src/widgets/payment_element.dart
#	packages/stripe_web/pubspec.yaml
… into web_deffered_payment

# Conflicts:
#	packages/stripe_platform_interface/CHANGELOG.md
#	packages/stripe_web/pubspec.yaml
Eduard Dumitrescu added 6 commits October 30, 2024 14:40
… into web_deffered_payment

# Conflicts:
#	packages/stripe/CHANGELOG.md
#	packages/stripe/pubspec.yaml
#	packages/stripe_js/CHANGELOG.md
#	packages/stripe_js/lib/src/api/payment_intents/confirm_payment_options.freezed.dart
#	packages/stripe_js/lib/src/js/elements/elements.dart
#	packages/stripe_js/pubspec.yaml
#	packages/stripe_platform_interface/CHANGELOG.md
#	packages/stripe_web/CHANGELOG.md
#	packages/stripe_web/lib/src/widgets/payment_element.dart
#	packages/stripe_web/pubspec.yaml
@dhoffer
Copy link

dhoffer commented Nov 28, 2024

Hi @EduardDumitrescu I am trying to implement Flutter web for Stripe CC payments. Sounlds like you are way ahead of me in implementing this. Could you send me your code that handles the Stripe CC payments for Flutter web? My email is [email protected], much appreciated.

Eduard Dumitrescu and others added 3 commits June 3, 2025 11:45
… into web_deffered_payment

# Conflicts:
#	packages/stripe/CHANGELOG.md
#	packages/stripe/pubspec.yaml
#	packages/stripe_js/CHANGELOG.md
#	packages/stripe_js/pubspec.yaml
#	packages/stripe_platform_interface/CHANGELOG.md
#	packages/stripe_platform_interface/pubspec.yaml
#	packages/stripe_web/CHANGELOG.md
#	packages/stripe_web/lib/src/web_stripe.dart
#	packages/stripe_web/lib/src/widgets/payment_element.dart
#	packages/stripe_web/pubspec.yaml
@ciprig
Copy link

ciprig commented Jul 10, 2025

Hi @remonh87 ,

Just checking in on this PR. This is a crucial fix for the Stripe deferred payments support on web.

We wanted to let you know that we have successfully deployed and validated this exact code in our production application, so we're confident in its stability.

The branch is updated and ready for review. Please let us know if there's anything we can do to help get this merged.

Thank you!

Copy link
Member

@remonh87 remonh87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR I think overall it looks good just left some remarks

@@ -1,6 +1,6 @@
name: flutter_stripe
description: Flutter library for Stripe. Supports PaymentSheets, Apple & Google Pay, SCA, PSD2 and much more.
version: 11.5.1
version: 11.6.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s not bump the version we will do this when we release

@@ -11,6 +10,7 @@ class ConfirmPaymentOptions with _$ConfirmPaymentOptions {
const factory ConfirmPaymentOptions({
/// The Elements instance that was used to create the Payment Element.
@ElementsConverter() required Elements elements,
String? clientSecret,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

Nit: let's add a doc here

The PaymentIntent's client secret.

@@ -1,3 +1,8 @@
## 11.6.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will define the version (I think we want to add some more) to this can be removed

@@ -1,6 +1,6 @@
name: stripe_js
description: Stripe.js bindings for dart. This package is used by Stripe web so that the Stripe js sdk can be invoked directly.
version: 6.4.0
version: 6.4.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here not needed to add a version

@@ -101,6 +102,19 @@ class MethodChannelStripe extends StripePlatform {
.parse(result: result!, successResultKey: 'paymentMethod');
}

@override
Future<PaymentMethod> createPaymentMethodWithElements() =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not prefer to add this method as we really want to stay close to the stripe react native implementation here.

@@ -427,6 +441,28 @@ class MethodChannelStripe extends StripePlatform {
return isSupported ?? false;
}

@override
Future<AvailableMobilePayOptions> availableMobilePayOptions({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the use of this method? we have a function called: isPlatformPaySupported

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@remonh87 I have exposed this method as well so it would be easier for a consumer to show hide google/apple pay buttons. With just isPlatformPaySupported you would have to do something like

if(isPlatformPaySupported && Platform.isAndroid) GooglePayButtonWidget()
instead of

if(availableMobilePayOptions.googlePay) GooglePayButtonWidget()

I believe I have addressed most of the comments so the merge request can be reviewed again. The only problem after the refactor was that after eliminating everything 'createPaymentMethodWithElements' related so that only 'createPaymentMethod' would remain I had to add an extra constructor to CreatePaymentMethodData which would handle the elements case. When multiple constructors are used freezed generates an extra 'runtimeType' parameter(when doing toJson) which was causing the js stripe method 'createPaymentMethod' to fail. I haven't been able to find anything in freezed which would allow me to remove that 'runtimeType' field so I removed it manually inside 'createPaymentMethod' from 'ExtensionCreatePaymentMethod'(not a very clean approach). Another approach would be to create another method inside 'ExtensionCreatePaymentMethod' which does the same thing as the existing one but receives another model with just the elements data(something like 'CreatePaymentMethodDataWithElements'). I'm open to any suggestion or approach or could leave it like this if you find it to be good enough.


const PaymentElement({
super.key,
required this.clientSecret,
this.clientSecret,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking maybe we should split the widget into two constructors to make it clear for consumer what to add. In case for:

without intent => mode, anount and currency are required

with intent => client secret is required.

Eduard Dumitrescu added 8 commits August 5, 2025 15:46
… into web_deffered_payment

# Conflicts:
#	packages/stripe_js/lib/src/api/payment_intents/confirm_payment_options.freezed.dart
#	packages/stripe_js/lib/src/api/payment_intents/confirm_payment_options.g.dart
#	packages/stripe_js/lib/src/api/payment_methods/create_payment_method_data.dart
#	packages/stripe_js/lib/src/api/payment_methods/create_payment_method_data.freezed.dart
#	packages/stripe_js/lib/src/api/payment_methods/create_payment_method_data.g.dart
#	packages/stripe_js/lib/src/api/payment_methods/payment_method.freezed.dart
#	packages/stripe_js/lib/src/api/payment_methods/payment_method.g.dart
#	packages/stripe_js/lib/src/js/payment_methods/create_payment_method.dart
#	packages/stripe_platform_interface/lib/src/models/payment_methods.freezed.dart
#	packages/stripe_platform_interface/lib/src/models/payment_methods.g.dart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants